﻿#include "VariablePanel.h"

#include <cassert>

#include <QtGui/QBrush>
#include <QtGui/QPainter>

#include "AbstractMappingWindow.h"
#include "NodeManager.h"

VariablePanel::VariablePanel( NodeManager* manager)
	: AbstractPanel("Variable", manager)
{
	this->_manager = manager;
	init();
	this->_width = 254;
}

VariablePanel::~VariablePanel()
{

}

void VariablePanel::init()
{
	initTitle("Variable",false);
}

void VariablePanel::setupPort()
{
	assert(false);
}

void VariablePanel::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget * widget)
{
	// 畫 Panel 的背景
	QPixmap backgroundPixmap(":/resource/vd_panel_bg.png");
	QBrush backgroundBrush(backgroundPixmap);
	painter->setBrush(backgroundBrush);
	painter->setPen(Qt::NoPen);
	painter->drawRect(0, 0, backgroundPixmap.width(), AbstractMappingWindow::SCENE_HEIGHT);

	// 畫 Panel title 的 Block
	painter->setBrush(QBrush(QColor("#222222")));
	painter->drawRect(0, 0, this->_width, TITLE_BLOCK_HEIGHT);
}

QRectF VariablePanel::boundingRect() const
{
	QPixmap backgroundPixmap(":/resource/vd_panel_bg.png");
	return QRectF(0, 0, backgroundPixmap.width(), AbstractMappingWindow::SCENE_HEIGHT);
}
